import { MyRequest } from '../index'

import type { IAccount, IuserInfoRoot, IuserMenuTreeRoot } from '@/types/index'

type accountLoginType = {
  code: number
  data: {
    id: number
    name: string
    token: string
  }
}

export function accountLoginRequest(account: IAccount) {
  return MyRequest.post<accountLoginType>({
    url: '/login',
    data: account
  })
}

export function getUserInfoById(id: number) {
  return MyRequest.get<IuserInfoRoot>({ url: `users/${id}` })
}

export function getUserMenusByRouleID(id: number) {
  return MyRequest.get<IuserMenuTreeRoot>({ url: `/role/${id}/menu` })
}
